package model.class1.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import common.SearchDto;

import model.class1.dto.Class1Dto;
import model.class1.dto.ResistDto;

public class Class1DaoImpl implements Class1Dao {
	private SqlSession sqlSession;
	public void setSqlSession(SqlSession sqlSession) {
		this.sqlSession = sqlSession;
	}

	@Override
	public List<Class1Dto> class1List(String state) {
		
		List<Class1Dto> list;
		if(state == null){
			list=sqlSession.selectList("class1.class1List",state);
		}
		else if(state.equals("multi")){//모든 state검색
		list= sqlSession.selectList("class1.class1ListAll");
		}
		else{
		list= sqlSession.selectList("class1.class1List",state);
		}
		return list;
	}

	@Override
	public void hitUp(int idx) {
		sqlSession.update("class1.hitUp",idx);
		
	}

	@Override
	public Class1Dto class1Detail(int idx) {
		Class1Dto dto=sqlSession.selectOne("class1.class1Detail",idx);
		return dto;
	}

	@Override
	public void class1Update(Class1Dto dto) {
		sqlSession.update("class1.class1Update",dto);
		
	}

	@Override
	public void class1Delete(int idx) {
		sqlSession.delete("class1.class1Delete",idx);
		
	}

	@Override
	public List<String> class1DateList(String date) {
		return sqlSession.selectList("class1.class1DateList", date);
	}

	@Override  // 강좌 개설 insert (!! 수강신청이 아님!!)
	public void class1Insert(Class1Dto cdto) {
		sqlSession.insert("class1.class1Insert", cdto);		
	}

	@Override
	public void class1ResistInsert(Class1Dto dto) {
		sqlSession.insert("class1.class1ResistInsert",dto);
		
	}

	@Override
	public List<Class1Dto> myResistList(SearchDto search) {
		return sqlSession.selectList("class1.myResistList", search);
	}

	@Override
	public List<Class1Dto> myClassList(SearchDto search) {
		return sqlSession.selectList("class1.myClasstList", search);
	}

	@Override
	public List<Class1Dto> adminClass1List(SearchDto search) {
		return sqlSession.selectList("class1.adminClassList", search);
	}

	@Override
	public void class1AdminPriceUpdate(Class1Dto dto) {
		sqlSession.update("class1.class1AdminPriceUpdate",dto);
	}

	@Override
	public List<Class1Dto> class1MyList(String userid) {
		List<Class1Dto> list;
		list=sqlSession.selectList("class1.class1MyList",userid);
		return list;
	}

	@Override
	public List<Class1Dto> class1MyOrderList(String userid) {
		List<Class1Dto> list;
		list=sqlSession.selectList("class1.class1MyOrderList",userid);
		return list;
	}

	@Override
	public ResistDto class1ResistList(int idx) {
		ResistDto dto=sqlSession.selectOne("class1.class1ResistList",idx);
		return dto;
	}

	@Override
	public Class1Dto class1ResistDetail(int idx) {
		System.out.println(idx);
		Class1Dto dto= sqlSession.selectOne("class1.class1ResistDetail",idx);
		return dto;
	}

	@Override
	public void class1ResistDelete(int idx) {
		System.out.println(idx);
		sqlSession.delete("class1.class1ResistDelete",idx);
	}

}
